    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.storebits.testsystem;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Ventsi
 */
@Entity
@Table(name = "journey")
@NamedQueries({
    @NamedQuery(name = "Journey.findAll", query = "SELECT j FROM Journey j")})
public class Journey implements Serializable {
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "price")
    private BigDecimal price;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "catalogNumber")
    private Integer catalogNumber;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "type")
    private String type;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "description")
    private String description;
    @OneToMany(mappedBy = "journey")
    private Collection<Journeyreservation> journeyreservationCollection;

    public Journey() {
    }

    public Journey(Integer catalogNumber) {
        this.catalogNumber = catalogNumber;
    }

    public Journey(Integer catalogNumber, String name, String type, String code, String description, BigDecimal price) {
        this.catalogNumber = catalogNumber;
        this.name = name;
        this.type = type;
        this.code = code;
        this.description = description;
        this.price = price;
    }

    public Integer getCatalogNumber() {
        return catalogNumber;
    }

    public void setCatalogNumber(Integer catalogNumber) {
        this.catalogNumber = catalogNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<Journeyreservation> getJourneyreservationCollection() {
        return journeyreservationCollection;
    }

    public void setJourneyreservationCollection(Collection<Journeyreservation> journeyreservationCollection) {
        this.journeyreservationCollection = journeyreservationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (catalogNumber != null ? catalogNumber.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Journey)) {
            return false;
        }
        Journey other = (Journey) object;
        if ((this.catalogNumber == null && other.catalogNumber != null) || (this.catalogNumber != null && !this.catalogNumber.equals(other.catalogNumber))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        String smallDescription = null;
        if(description.length() > 50) {
            smallDescription = description.substring(0, 50);
            smallDescription += "...";
        }
        else {
            smallDescription = description;
        }
        return name + ", " + smallDescription + ", price: " + price + 
                ", catalog code: " + code;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    
}
